// page/order/order.js
var util = require("../../utils/util.js");
Page({
  data: {
    checked: false,
    state: true,
    contentHidden: true,
    orderHidden: false,
    payHidden: true,
    price: 24,
    xorder:{
      sort:"",
      title:"",
      price:0,
      name:"",
      time:"",
      id:"",
      phone:""
    },
    detail:{}
  },
  onLoad:function(options){
    var page = this;
    var xorder = this.data.xorder;
    var sort = options.sort;
    var detail = JSON.parse(options.detail);    
    
     this.setData({
       detail:JSON.stringify(detail)
     });
     var payType = options.payType;
     xorder.sort = sort;
     xorder.title = detail.Title;
     xorder.price = detail.Price;
     xorder.name = getApp().globalData.userInfo.nickName;
     // phone get from server later,ignore it now
     var UserID = getApp().globalData.userId;
     var params = {   
       Param:{
         UserID: UserID,
         Pay_OrderType:payType,
         BusinessID:detail.ID||detail.MsgID||detail.PackageID
       },
       Action:503
     };
     util.reqMedia(params,function(value){
       xorder.id = value.xy_OutTradeNo;
       xorder.time = value.CreateDate;      
         page.setData({
              xorder:xorder
         });
        });
  },
  onSwitch: function (e) {
    if (this.data.state) {
      this.setData({
        checked: true,
        state: false,
        contentHidden: true
      });
    } else {
      this.setData({
        checked: false,
        state: true,
        contentHidden: false
      });
    }
  },
  onCheckContent: function () {
    this.setData({
      contentHidden: false,
      checked: false,
      state: true
    });
  },
});